﻿using BarrageGameAssistant.Core.Configs;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BarrageGameAssistant.UIForms
{
    public partial class FrmGlobalSetting : Form
    {
        /// <summary>
        /// 程序配置
        /// </summary>
        public Settings? Settings { get; set; }

        public FrmGlobalSetting()
        {
            InitializeComponent();
        }

        private void FrmGlobalSetting_Load(object sender, EventArgs e)
        {
            if (Settings != null)
            {
                this.chkAutoLoadGame.Checked = Settings.AutoLoadGame;
                this.cbbCaptureFrameRate.Text = Settings.CaptureFrameRate.ToString();

                this.nudCaptureFixDisplayPixel.Value = Settings.CaptureFixDisplayPixel;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            if (Settings != null)
            {
                Settings.AutoLoadGame = this.chkAutoLoadGame.Checked;
                Settings.CaptureFrameRate = Convert.ToInt32(this.cbbCaptureFrameRate.Text);
                Settings.CaptureFixDisplayPixel = Convert.ToInt32(this.nudCaptureFixDisplayPixel.Value);
            }

            this.DialogResult = DialogResult.OK;
        }
    }
}
